package com.gwz.bus.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.gwz.bus.domain.Provider;
import com.gwz.bus.mapper.ProviderMapper;
import com.gwz.bus.service.ProviderService;
import com.gwz.bus.vo.ProviderVo;
import com.gwz.sys.utils.DataGridView;

@Service
@Transactional
public class ProviderServiceImpl implements ProviderService {
	
	@Autowired
	private ProviderMapper ProviderMapper;
	
	@Override
	public DataGridView queryAllProvider(ProviderVo ProviderVo) {
		Page<Object> page = PageHelper.startPage(ProviderVo.getPage(), ProviderVo.getLimit());
		List<Provider> data = ProviderMapper.queryAllProvider(ProviderVo);
		return new DataGridView(page.getTotal(), data);
	}

	@Override
	public void addProvider(ProviderVo ProviderVo) {
		ProviderMapper.insertSelective(ProviderVo);
	}

	@Override
	public void updateProvider(ProviderVo ProviderVo) {
		ProviderMapper.updateByPrimaryKeySelective(ProviderVo);
	}

	@Override
	public void deleteProvider(ProviderVo ProviderVo) {
		ProviderMapper.deleteByPrimaryKey(ProviderVo.getId());
	}

	@Override
	public void batchDelete(ProviderVo ProviderVo) {
		Integer[] ids = ProviderVo.getIds();
		for (Integer id : ids) {
			ProviderMapper.deleteByPrimaryKey(id);
		}
	}

	@Override
	public List<Provider> queryAllProviderForList(ProviderVo providerVo) {
		return ProviderMapper.queryAllProvider(providerVo);
	}

}
